package com.efei.jdbc.dynamic.query.filter;

import com.alibaba.fastjson.JSONObject;
import com.efei.jdbc.config.SysQueryConfiguation;
import com.efei.jdbc.dynamic.query.element.QueryElement;
import com.efei.jdbc.dynamic.query.service.SysQueryService;
import com.efei.jdbc.sql.SqlSelect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public abstract class AbstractQueryFilter implements QueryFilter{

    protected Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    protected HttpServletRequest request;

    @Autowired
    protected HttpServletResponse response;

    @Autowired
    private SysQueryConfiguation queryConfiguation;

    @Override
    public QueryElement getQueryElment() {
        // TODO Auto-generated method stub
        String querId = (String)request.getAttribute(SysQueryService.QUERY_ID);
        QueryElement qe = queryConfiguation.getQueryElment(querId);
        return qe;
    }

    @Override
    public void before(SqlSelect sql, JSONObject parameter) {
        // TODO Auto-generated method stub

    }

    @Override
    public void after(Object result, JSONObject parameter) {
        // TODO Auto-generated method stub

    }
}
